<?
require_once('ValidatorBase.php');

class RegexValidator extends ValidatorBase {
	private $regex;

	// ACCESSORS
	public function setRegex($value) { $this->regex= $value; return $this; }
	public function getRegex() { return $this->regex; }

	protected function doValidate($value) {
		if (!is_string($value) || !preg_match($this->getRegex(),$value))
			throw new ValidatorException($this,$value);
	}
}
